package com.itheima.d3_abstract;

public class Test {
    public static void main(String[] args) {
        String type = "Wechat";
        OnlinePay pay = null;
        if ("Alipay".equals(type)){
            pay = new Alipay();
        }else if("Wechat".equals(type)){
            pay = new WechatPay();
        }else {
            System.out.println("暂不支持该支付方式");
        }
        pay.pay(99.9);
    }
}
abstract class OnlinePay{
    public abstract void pay(double money);
}
class Alipay extends OnlinePay{
    @Override
    public void pay(double money) {
        System.out.println("支付宝支付了" + money + "元");
    }
}
class WechatPay extends OnlinePay{
    @Override
    public void pay(double money) {
        System.out.println("微信支付了" + money + "元");
    }
}
